package com.menghao.cloud.service.provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>服务-2.<br>
 *
 * @author MarvelCode.
 */
@EnableDiscoveryClient
@SpringBootApplication
@RestController
public class CloudProvider {

    private static Logger LOG = LoggerFactory.getLogger(CloudProvider.class);

    @Autowired
    private DiscoveryClient client;

    public static void main(String[] args) {
        SpringApplication.run(CloudProvider.class, args);
    }

    @RequestMapping("hello")
    public String sayHello() {
        ServiceInstance instance = client.getLocalServiceInstance();
        LOG.info("/hello, host:" + instance.getHost() + ", service_id:" + instance.getServiceId());
        return "hello world";
    }

}
